package com.maiji.cloud.cfgbeans;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import java.util.Arrays;
import java.util.List;

@Configuration
public class InterceptorConfig extends WebMvcConfigurerAdapter {

    private List<String> excludePathPatterns = Arrays.asList("/swagger-resources/**", "/webjars/**", "/images/**", "/v2/**", "/configuration/**", "/error",
            "/capitalInteface/weixinPayCallBack", "/capitalInteface/refundCallBack", "/capitalInteface/alipayCallBack");

	 @Override
	    public void addInterceptors(InterceptorRegistry registry) {
	        registry.addInterceptor(this.LoginInterceptor()).addPathPatterns("/**")
                    .excludePathPatterns((String[]) excludePathPatterns.toArray());
	        super.addInterceptors(registry);
	    }

    @Bean
    public HandlerInterceptor LoginInterceptor () {
        return new LoginInterceptor();
    }

}

